# We can make use of signals and slots that are provided by widgets. We don't need to rely solely on the signals
# that are provided by the Qt Widgets. Signals are created using the Signal class. 
# A simple signal definition would be - tapped = Signal()
# Then when the conditions for the object being tapped are satisfied, we can call the signal's emit method and the
# signal is emitted, calling any 'slots' to which it is connected - thing.tapped.emit()
   
from __future__ import print_function
import sys
from PySide import QtGui, QtCore
   
class PunchingBag(QtCore.QObject):
     
    # Define a signal or a number of signals
    punched = QtCore.Signal()
    kicked = QtCore.Signal(int)
     
    def __init__(self):
#         super(PunchingBag, self).__init__()
        QtCore.QObject.__init__(self)
         
           
    def punch(self):
        self.punched.emit()
 
@QtCore.Slot()
def sayPunched():
    print("Bag punched")
       

pbag = PunchingBag()
pbag.punched.connect(sayPunched)
pbag.punch()

